package com.tang.portal.controller.admin.sys;

import com.tang.framework.core.controller.BaseController;
import com.tang.framework.core.domain.HttpResult;
import com.tang.common.model.req.ReqPage;
import com.tang.portal.component.harbor.model.Repository;
import com.tang.portal.facade.admin.sys.HarborFacade;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author tang jun liang
 * @Date 2023/6/21 10:33
 */
@Tag(name = "harbor人工制品接口")
@RequestMapping(value = "/sys/harbor")
@RestController
public class HarborController extends BaseController {

    @Resource
    private HarborFacade harborFacade;


    @Operation(summary = "获取某一个仓库下的所有人工制品")
    @GetMapping("/{projectName}/{repositoryName}/artifacts")
    public HttpResult<List<Map<?,?>>> artifacts(@PathVariable(value = "projectName") String projectName,
                                                @PathVariable(value = "repositoryName") String repositoryName) {
        return harborFacade.artifacts(projectName, repositoryName);
    }



    @Operation(summary = "获取某一个项目下的所有仓库")
    @PostMapping("/{projectName}/repositories")
    public HttpResult<List<Repository>> repositories(@PathVariable(value = "projectName") String projectName, @RequestBody ReqPage page){
        return harborFacade.repositories(projectName, page);
    }
}
